﻿@model STX.Admin.Models.BizSupplier.ChooseModel
@{
    ViewBag.Title = "Edit";
    Layout = null;
    var i = 0;
}
<form class="pageForm addpage" action="@Url.Action("SaveChooseMaterial")" method="post">
   
    <input type="hidden" value="@Model.Id" name="Id" />

    <div style=" height:100%; width:100%; overflow:hidden" class="verticalSplitContainer">
        <div class="pageFormContent" ratio="*">
           
            <table style="width:100%">
                <tr>
                    <td width="15%">地方：</td>
                    <td width="85%" colspan="3">@Model.AreaName</td>
                </tr>
                <tr>
                    <td width="15%"> 供应商名称：</td>
                    <td width="35%"> @Model.Name</td>
                    <td width="15%">联系人：</td>
                    <td width="35%">@Model.Contacter</td>
                </tr>
                <tr>
                    <td>电话：</td>
                    <td>@Model.Tel</td>
                    <td>Email：</td>
                    <td>@Model.EMail</td>
                </tr>
            </table>
            <br/>
            <h4 style=" background: #b0e0e6; padding: 6px;">选择物料 </h4>
            <table style="width:100%" id="selectMaterial1">
                <tr>
                    <td style="width:20%">物料名称</td>
                    <td style="width:10%">编号</td>
                    <td style="width:50%">具体要求</td>
                    <td style="width:10%">单位</td>
                    <td style="width:10%">操作</td>
                </tr>
                @foreach (var item in Model.QuotePriceTemplates)
                {
                    var trbg = i%2 == 0 ? "#ffdead" : "palegreen";
                    var tdbg = "none";
                    var inputchecked = "";
                    if (Model.PriceTemplatesAry.Contains(item.Id))
                    {
                        inputchecked = " checked='checked' ";
                        tdbg = "#ff0000";
                    }
                    <tr style="background: lightsteelblue">
                        <td style="width: 20%; background: @tdbg">@item.Name</td>
                        <td style="width: 10%; background: @tdbg">@item.Code</td>
                        <td style="width: 50%; background: @tdbg">@item.Required</td>
                        <td style="width: 10%; background: @tdbg">@item.Unit</td>
                        <td style="width: 10%; background: @tdbg"><input type="checkbox" name="PriceTemplatesAry" value="@item.Id"@inputchecked /></td>
                    </tr>
                    <tr style="background:#d3e1f3">
                        <td colspan="5"> 已绑定给供应商:
                            @foreach (var supplier in item.Suppliers)
                            {
                                <font color="blue">@supplier.Name &nbsp; &nbsp;</font>
                            }
                        </td>
                    </tr>
                    <tr>
                        <td colspan="5" style="height:5px"></td>
                    </tr>
                    i++;
                }
            </table>
        </div>

        <div class="formBar" ratio="#30">
            <ul>
                <div class="simplebutton"><div class="r"><button type="button" class="submit">保存</button></div></div>
            </ul>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(function () {
        $("#selectMaterial1 input[type='checkbox']").click(function () {
            var $this = $(this);
            if ($this.attr("checked")) {
                $this.parent().parent().find("td").css("background", "#ff0000");
            } else {
                $this.parent().parent().find("td").css("background", "none");
            }
        });
    });
</script>